<?php $this->load->view('header/admin'); ?>
<div id="main">
    <div class="container">
        <div class="span-17 colborder" id="content">
        <?php if (isset($messages)) echo $messages; ?>
            <h3 class="caps">People</h3>
            <div class="span-17 box last">
                <p>We have <?php echo count($people); ?> member(s) in this club</p>
                <?php if ($people): ?>
                <div id="info" class="span-17 last">
                    <?php $index = 1; $count = count($people); $perCol = ceil($count / 3); ?>
                    <?php foreach($people as $p): ?>
                        <?php if ($index == 1): ?><dl class="span-5"><?php endif; ?>
                        <dt class="caps prepend-top">
                            <?php echo anchor('profile/person/edit/'.$p->id, $p->name, 'class="club-info" id="club-'.$p->id.'"')?>
                            [<?php echo anchor('admin/members/users/delete/'.$club->id.'/'.$p->id, 'x')?>]
                        </dt>
                    <?php if ($index >= $perCol): ?></dl><?php $index = 0; endif; $index++ ?>
                <?php endforeach; ?>
                </div>
            <?php endif; ?>
            </div>
                    <div class="box span-17 last">
                        <p>Enter a name to search and then add the person to this club</p>
                        <?php echo form_open('admin/members/users/search/'.$club->id); ?>
                        <p>
                            <label for="user_term" id="user_name" style="display: inline">Search</label> 
                            <input type="text" id="user_autocomplete" name="user_term" style="display: inline" />
                            <input type="submit" name="action" value="Search" />
                        </p>
                        <?php echo form_close(); ?>
                        
                        <?php if (isset($user_search_results) && count($user_search_results) > 0): ?>
                        <?php echo form_open('admin/members/users/add/'.$club->id); ?>
                        <p>
                            <label for="person" id="user_name">Results</label>
                            <?php echo form_dropdown('user_id', $user_search_results); ?>
                        </p>
                        <p style="text-align: right; margin-right: 10px">
                            <input type="submit" name="action" value="Add" />
                        </p>
                        <?php echo form_close(); ?>
                        <?php endif; ?>
                        <?php if (isset($user_search_results) && count($user_search_results) == 0): ?>
                        <p>There are no results for your query.</p>
                        <?php endif; ?>
                    </div>
        </div> <!-- end content -->
        <?php $this->load->view('menu/admin')?>
    </div> <!-- end container -->
</div> <!-- end main -->
<?php $this->load->view('footer/standard');?>
